Skip to content

fix(math): restore priority-based comment routing (regression from #1961) - #2611

Merged
jucor merged 1 commit into
edgefrom
spr/edge/ec8e2093
Jul 18, 2026
Merged

fix(math): restore priority-based comment routing (regression from #1961)#2611
jucor merged 1 commit into
edgefrom
spr/edge/ec8e2093

Conversation

@jucor

@jucor jucor commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

The :comment-priorities node passed the meta-tid lookup value
(if meta-tids (get meta-tids tid 0) 0) into priority-metric's is-meta
argument. (get meta-tids tid 0) returns 0 for non-meta tids, and 0 is
TRUTHY in Clojure, so (if is-meta ...) took the meta branch for EVERY
comment — every priority collapsed to meta-priority^2 = 49. The TypeScript
server's selectProbabilistically then degraded to uniform-random next-comment
selection, reverting routing to its pre-2018 behavior.

Introduced by #1961 (2025-03-15, "cutoff for large-convo processing if

5000 comments"), which changed the meta-tid default from (meta-tids tid)
(nil for non-meta) to (get meta-tids tid 0).

Fix: pass a real boolean — (priority-metric (contains? meta-tids tid) ...).
contains? is false for a non-meta tid and false when meta-tids is nil,
restoring meta=49 / non-meta=importance*novelty.

Verified end-to-end: a math image built with this fix regenerates the vw
cold-start blob with varied priorities (125 distinct, 5.16-61.95) instead of
all-49.

Scope: Clojure only, which is what feeds production routing. The Python port
still mirrors the bug (priority_metric returns META_PRIORITY**2). Un-mirroring
it revealed that Python and Clojure priorities are not yet at parity
(rank-uncorrelated on vw), so the Python un-mirror + cold-start blob
regeneration is deferred to #2571, pending extremity/PCA parity (D1/D1b).
See delphi/docs/CLJ-PARITY-FIXES-JOURNAL.md (2026-07-17).

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

commit-id:ec8e2093


Stack:


⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

jucor added a commit that referenced this pull request Jul 17, 2026
…ce (#2612)

Adds delphi/docs/MATH_ALGORITHM_HISTORY.md — a git-archaeology reference of the
core Polis math algorithms (comment routing, PCA/projection, extremity/repness,
clustering, consensus/moderation): introductions, numeric-output-changing edits,
and bugs, with verified commit hashes and dates. Includes the 2025 comment-routing
regression (#1961, fixed in #2611), the pre-2018 uniform-random routing history,
and how to map conversations to algorithm versions via the prod deploy timeline.

Sourced entirely from public git history and code — no production data.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

commit-id:31321c47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores the intended priority-weighted comment routing by fixing meta-comment detection in the Clojure math pipeline (preventing all comments from being treated as meta due to Clojure truthiness of 0). This re-enables non-uniform priorities so downstream routing (TS server sampling) behaves as designed.

Changes:

  • Fix :comment-priorities to pass a real boolean to priority-metric via (contains? meta-tids tid).
  • Document the parity implications and current Python↔Clojure priority mismatch in the Delphi parity planning docs.
  • Add an append-only journal entry describing the regression, fix, and discovered parity blocker.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
math/src/polismath/math/conversation.clj Fixes meta detection for priority computation to prevent all priorities collapsing to 49.
delphi/docs/PLAN_DISCREPANCY_FIXES.md Notes the newly-unmasked D12 parity blocker and cautions against un-mirroring Python yet.
delphi/docs/CLJ-PARITY-FIXES-JOURNAL.md Records the routing regression fix and the discovered non-parity details for future follow-up work.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread math/src/polismath/math/conversation.clj Outdated
Comment thread math/src/polismath/math/conversation.clj
@jucor
jucor force-pushed the spr/edge/ec8e2093 branch from 49d8503 to b86d4e6 Compare July 17, 2026 02:00
)

The `:comment-priorities` node passed the meta-tid lookup value
`(if meta-tids (get meta-tids tid 0) 0)` into `priority-metric`'s `is-meta`
argument. `(get meta-tids tid 0)` returns `0` for non-meta tids, and `0` is
TRUTHY in Clojure, so `(if is-meta ...)` took the meta branch for EVERY
comment — every priority collapsed to `meta-priority^2 = 49`. The TypeScript
server's `selectProbabilistically` then degraded to uniform-random next-comment
selection, reverting routing to its pre-2018 behavior.

Introduced by #1961 (2025-03-15, "cutoff for large-convo processing if
> 5000 comments"), which changed the meta-tid default from `(meta-tids tid)`
(nil for non-meta) to `(get meta-tids tid 0)`.

Fix: pass a real boolean — `(priority-metric (contains? meta-tids tid) ...)`.
`contains?` is false for a non-meta tid and false when `meta-tids` is nil,
restoring meta=49 / non-meta=importance*novelty.

Verified end-to-end: a math image built with this fix regenerates the vw
cold-start blob with varied priorities (125 distinct, 5.16-61.95) instead of
all-49.

Scope: Clojure only, which is what feeds production routing. The Python port
still mirrors the bug (`priority_metric` returns META_PRIORITY**2). Un-mirroring
it revealed that Python and Clojure priorities are not yet at parity
(rank-uncorrelated on vw), so the Python un-mirror + cold-start blob
regeneration is deferred to #2571, pending extremity/PCA parity (D1/D1b).
See delphi/docs/CLJ-PARITY-FIXES-JOURNAL.md (2026-07-17).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

commit-id:ec8e2093
@jucor
jucor force-pushed the spr/edge/ec8e2093 branch from b86d4e6 to 2cfa2c3 Compare July 17, 2026 16:24
@jucor
jucor merged commit 424dcae into edge Jul 18, 2026
4 checks passed
@jucor
jucor deleted the spr/edge/ec8e2093 branch July 18, 2026 02:53
colinmegill pushed a commit that referenced this pull request Sep 8, 2026
…gression reference

Adds `delphi/docs/MATH_ALGORITHM_HISTORY.md` — a git-archaeology reference of the core Polis math algorithms (comment routing, PCA/projection, extremity/repness, clustering, consensus/moderation): when each was introduced, every edit that changed numeric output, and known bugs, with verified commit hashes and dates. It includes the 2025 comment-routing regression (#1961, fixed in #2611), the pre-2018 uniform-random routing history, and a guide to mapping conversations to algorithm versions via the production deploy timeline.

Sourced entirely from public git history and code — no production data.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

commit-id:31321c47
colinmegill pushed a commit that referenced this pull request Sep 8, 2026
…d) + Q2 prev-tick group-votes

## What

Two changes to comment prioritization:

- Restore the real `priority_metric` branching formula in BOTH engine modes. Clojure HEAD passes a real boolean since #2611 (conversation.clj:686, merged 2026-07-18), so the all-49 mirror of bug #1961 (the meta-tid routing bug that flattened every comment's priority to ~49, which #2571 had us reproduce for parity) is no longer the parity behavior — the correct formula is.
- Replicate quirk Q2 (`delphi/docs/CLOJURE_QUIRKS.md`): Clojure's `:comment-priorities` node SHADOWS its current-tick group-votes input with `(:group-votes conv)` — the PREVIOUS tick's stored value (conversation.clj:658). clojure-legacy mode (the engine setting that reproduces the old Clojure engine's behavior exactly) now consumes the captured previous-tick group-votes (`{}` on the first tick, matching Clojure's nil); improved mode keeps the current-tick read.

## How it works

The current tick's group-votes are stored on `self.group_votes` each tick in both modes (like `self.pca`), as the in-memory analogue of Clojure persisting `:group-votes` in `math_main` (the math results table). The restart seam — reloading group-votes on `from_dict` / poller reload — is deferred to the poller equivalence phase and noted in the journal.

Stale-mirror test sites reworked:

- The designed xfail on `test_priority_metric_non_meta_squared` is harvested: the formula test now gates.
- `TestD12CommentPriorities` now pins varied (non-all-49) Python output plus coverage, instead of the mirror signature.
- The exact-value comparison in `test_legacy_clojure_regression.py::test_comment_priorities` is xfailed for ALL variants — the reference blobs predate the Clojure #2611 fix, so value parity is validated by the H-B replay battery (the `scripts/certify.py` Clojure-vs-Python replay comparison) until the blobs are regenerated with a fixed generator.

## Testing

TDD: `tests/test_priority_unmirror.py` — RED observed (formula tests fail on the mirror; prev-tick flow + group_votes storage fail on the old wiring), 7 GREEN after. Targeted runs: 13 passed (unmirror + float-serialization), 21 passed (D12/priority subset), 4 xfailed (legacy regression value comparisons).

commit-id:a85047a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants